using System;
using Microsoft.SPOT;
using System.Collections;

namespace MicroContainer
{      
   public abstract class BaseContainer : IMicroContainer
   {
      protected virtual ArrayList GetMappings()
      {
         return null;
      }

      #region IMicroContainer Members
      public object Resolve(Type type, string name)
      {
         foreach (Mapping mapping in GetMappings())
         {
            if (mapping.Type == type && (name == null || name == mapping.Name))
            {
               return mapping.BuildMethod(this);
            }
         }
         throw new ResolutionException("No mapping leading to " + type + " with name " + name + " found.");
      }
      #endregion
   }
}
